package com.dxg.msns.user.controller;

import com.dxg.msns.common.pojo.PageResult;
import com.dxg.msns.common.util.Result;
import com.dxg.msns.user.pojo.User;
import com.dxg.msns.user.service.SingerGradeService;
import com.dxg.msns.user.service.SingerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/user/singers")
public class SingerController {

    @Autowired
    private SingerService singerService;
    @Autowired
    private SingerGradeService singerGradeService;

    @GetMapping("/grade")
    public ResponseEntity<String> gradeSinger(@RequestParam String singerId,
                                              @RequestParam String userId,
                                              @RequestParam Integer grade) {
        String result = singerGradeService.rateSinger(singerId, userId, grade);
        return ResponseEntity.ok(result);
    }
    @GetMapping("/page")
    public Result<List<User>> queryUsersByPage(@RequestParam("name") String name) {
        List<User> singers = singerService.querySingersByPage(name);
        return Result.success(singers);
    }

    @GetMapping("/queryByUid")
    public Result<User> queryUsersByUid(@RequestParam("uid") String uid) {
        User singer = singerService.querySingersByUid(uid);
        return Result.success(singer);
    }

    @GetMapping("/getApplySinger")
    public Result<List<User>> getApplySinger(@RequestParam("name") String name) {
        List<User> singers = singerService.getApplySinger(name);
        return Result.success(singers);
    }

    @GetMapping("/getNotSinger")
    public Result<List<User>> getNotSinger() {
        List<User> singers = singerService.getNotSinger();
        return Result.success(singers);
    }
}
